﻿using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO_Layer
{
    class Sqlconnector
    {
        MySqlConnection mysqlconnection;

        public MySqlConnection Mysqlconnection
        {
            get { return mysqlconnection; }
            set { mysqlconnection = value; }
        }

        public Sqlconnector()
        {

            try
            {
                mysqlconnection = new MySqlConnection(ConfigurationManager.ConnectionStrings["MysqlCS"].ConnectionString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

        public void Open()
        {
            try
            {
                mysqlconnection.Open();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());                
            }
        }

        public void Close()
        {
            try
            {
                mysqlconnection.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }   
    }
}
